package com.dreamwhale.machinery.goods.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dreamwhale.machinery.config.DataResult;
import com.dreamwhale.machinery.config.StringUtils;
import com.dreamwhale.machinery.dao.*;
import com.dreamwhale.machinery.entity.*;
import com.dreamwhale.machinery.goods.entity.*;
import com.dreamwhale.machinery.goods.mapper.*;
import com.dreamwhale.machinery.goods.service.*;
import com.dreamwhale.machinery.logistics.entity.TransportCompanyInfo;
import com.dreamwhale.machinery.logistics.entity.TransportInfo;
import com.dreamwhale.machinery.logistics.mapper.TransportCompanyInfoMapper;
import com.dreamwhale.machinery.logistics.mapper.TransportInfoMapper;
import com.dreamwhale.machinery.logistics.service.TransportCompanyInfoService;
import com.dreamwhale.machinery.logistics.service.TransportInfoService;
import com.dreamwhale.machinery.service.*;
import com.dreamwhale.machinery.user.entity.UserShop;
import com.dreamwhale.machinery.user.entity.YxUser;
import com.dreamwhale.machinery.user.entity.YxUserAddress;
import com.dreamwhale.machinery.user.mapper.YxUserAddressMapper;
import com.dreamwhale.machinery.user.mapper.YxUserMapper;
import com.dreamwhale.machinery.user.service.YxUserAddressService;
import com.dreamwhale.machinery.user.service.YxUserService;
import com.dreamwhale.machinery.utils.RedisUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.util.CollectionUtils;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.sql.DataSource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 二手机械出售 前端控制器
 * </p>
 *
 * @author Author
 * @since 2020-05-28
 */
@RestController
@RequestMapping("/user")
public class MachineSellController {

    @Resource
    private MachineSellService machineSellService;

    @Resource
    private MachineBuyService machineBuyService;

    @Resource
    private DriverInfoService driverInfoService;

    @Resource
    private DriverWorkInfoService driverWorkInfoService;

    @Resource
    private ProjectSeekService projectSeekService;

    @Resource
    private TransportCompanyInfoService transportCompanyInfoService;

    @Resource
    private TransportInfoService transportInfoService;

    @Resource
    private YxUserService yxUserService;

    @Resource
    private YxUserMapper yxUserMapper;

    @Resource
    private YxUserAddressService yxUserAddressService;

    @Resource
    private YxUserAddressMapper yxUserAddressMapper;

    @Resource
    private DriverInfoMapper driverInfoMapper;

    @Resource
    private DriverWorkInfoMapper driverWorkInfoMapper;

    @Resource
    private MachineSellMapper machineSellMapper;

    @Resource
    private MachineBuyMapper machineBuyMapper;

    @Resource
    private ProjectSeekMapper projectSeekMapper;

    @Resource
    private TransportInfoMapper transportInfoMapper;

    @Resource
    private TransportCompanyInfoMapper transportCompanyInfoMapper;

    @Resource
    private UserShopCollectService userShopCollectService;

    @Resource
    private UserShopCollectMapper userShopCollectMapper;

    @Resource
    private VipArticleCollectService vipArticleCollectService;

    @Resource
    private VipArticleCollectMapper vipArticleCollectMapper;
    @Resource
    private VipArticleMapper vipArticleMapper;

    @Resource
    private ClassifyMapper classifyMapper;

    @Resource
    private LeaseService leaseService;

    @Resource
    private LeaseMapper leaseMapper;

    @Resource
    private BywhShopService bywhShopService;

    @Resource
    private BywhShopMapper bywhShopMapper;

    @Resource
    private MachineShowService machineShowService;

    @Resource
    private ProductBrandMapper productBrandMapper;

    @Resource
    private InfoCollectService infoCollectService;
    @Resource
    private RedisUtils<String> strRedisUtils;



    /**
     * 查询我的发布
     *
     * @param userId
     * @param page
     * @param limit  1   司机招聘  2   司机找工作  3   找机械   4   二手机械出售     5   找工程 6   物流信息 7   托运信息 8去租赁
     * @return
     */
    @RequestMapping("/selectMyMeassagesbyType")
    public DataResult selectMyMeassagesbyType(Integer userId, Integer page, Integer limit, Integer types) {

        PageHelper.startPage(page, limit, true);
        if (types == 1) {
            //找司机
            List<DriverInfo> driverInfo = driverInfoService.selectDriverInfoMap(userId);
            PageInfo<DriverInfo> pages = new PageInfo<>(driverInfo);
            return DataResult.ok(pages);
        } else if (types == 2) {
            //找工作
            List<DriverWorkInfo> driverWorkInfo = driverWorkInfoService.selectDriverWorkInfoMap(userId);
            PageInfo<DriverWorkInfo> pages = new PageInfo<>(driverWorkInfo);
            return DataResult.ok(pages);
        } else if (types == 3) {
            //找机械
            List<MachineBuy> machineBuy = machineBuyService.selectMachineBuyMap(userId);
            PageInfo<MachineBuy> pages = new PageInfo<>(machineBuy);
            return DataResult.ok(pages);

        } else if (types == 4) {
            //卖机械
            List<MachineSell> machineSell = machineSellService.selectMachineSellMap(userId);
            PageInfo<MachineSell> pages = new PageInfo<>(machineSell);
            return DataResult.ok(pages);
        } else if (types == 5) {
            //找工程
            List<ProjectSeek> projectSeek = projectSeekService.selectProjectSeekMap(userId);
            PageInfo<ProjectSeek> pages = new PageInfo<>(projectSeek);
            return DataResult.ok(pages);
        } else if (types == 6) {
            //物流信息
            List<TransportCompanyInfo> transportCompanyInfo = transportCompanyInfoService.selectTransportCompanyInfoMap(userId);
            PageInfo<TransportCompanyInfo> pages = new PageInfo<>(transportCompanyInfo);
            return DataResult.ok(pages);
        } else if (types == 7) {
            //托运信息
            List<TransportInfo> transportInfo = transportInfoService.selectTransportInfoMap(userId);
            PageInfo<TransportInfo> pages = new PageInfo<>(transportInfo);
            return DataResult.ok(pages);
        } else {
            //去租赁
            List<Lease> lease = leaseService.selectLeaseByUserId(userId);
            PageInfo<Lease> pages = new PageInfo<>(lease);
            return DataResult.ok(pages);
        }


    }


    /**
     * 修改密码
     *
     * @param yxUser
     * @return
     */
    @RequestMapping("/updateMyPassWords")
    public DataResult updateMyPassWords(YxUser yxUser) {
        YxUser user = yxUserMapper.selectById(yxUser.getUid());
        String s = DigestUtils.md5DigestAsHex(yxUser.getPassword().getBytes());
        if (!s.equals(user.getPassword()))
            return new DataResult(300, "密码错误", null);
        String s1 = DigestUtils.md5DigestAsHex(yxUser.getPwd().getBytes());
        user.setPassword(s1);
        user.setPwd(s1);
        int i = yxUserMapper.updateById(user);
        if (i > 0) {
            return DataResult.ok("修改成功");
        }
        return DataResult.build(300, "修改失败");
    }



    /**
     * 忘记密码
     *
     * @param yxUser
     * @return
     */
    @RequestMapping("/updateMyPwd")
    public DataResult updateMyPwd(YxUser yxUser, String code) {
        QueryWrapper<YxUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("phone",yxUser.getPhone()).eq("status",1);
        YxUser user = yxUserMapper.selectList(queryWrapper).get(0);
         if(user==null){
             return DataResult.build(300,"你还没有账号");
         }
        String read = strRedisUtils.read(String.format("Sms-%s", yxUser.getPhone()));
        if (!read.equals(code)) {
            return new DataResult(300, "验证码不正确", null);
        }
        String s = DigestUtils.md5DigestAsHex(yxUser.getPwd().getBytes());
        String s1 = DigestUtils.md5DigestAsHex(yxUser.getPwd().getBytes());
        user.setPassword(s1);
        user.setPwd(s1);
        int i = yxUserMapper.updateById(user);
        if (i > 0) {
            return DataResult.ok("修改成功");
        }
        return DataResult.build(300, "修改失败");
    }


    /**
     * 添加地址
     *
     * @param yxUserAddress
     * @return
     */
    @RequestMapping("/insertYxUserAddress")
    public DataResult insertYxUserAddress(YxUserAddress yxUserAddress) {
        int count = yxUserAddressService.selectYxUserAddress(yxUserAddress.getUid());
        if (count == 0) {
            yxUserAddressService.insertYxUserAddress(yxUserAddress);
            return DataResult.ok("1");
        } else {

            QueryWrapper<YxUserAddress> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("uid", yxUserAddress.getUid()).eq("is_default", 0).eq("is_del", 0);
            YxUserAddress userAddress = yxUserAddressMapper.selectOne(queryWrapper);
            userAddress.setIsDefault(1);
            yxUserAddressService.updateYxUserAddress(userAddress);

            yxUserAddressService.insertYxUserAddress(yxUserAddress);
            System.out.println(yxUserAddress);
            return DataResult.ok("2");
        }
    }

    /**
     * 查询我的地址
     *
     * @param userId
     * @return
     */
    @RequestMapping("/selectYxUserAddressByUserId")
    public DataResult selectYxUserAddressByUserId(Integer userId) {

        QueryWrapper<YxUserAddress> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uid", userId).eq("is_del", 0);

        return DataResult.ok(yxUserAddressMapper.selectList(queryWrapper));
    }


    /**
     * 根据id查询我的地址
     *
     * @param YxUserAddressId
     * @return
     */
    @RequestMapping("/selectYxUserAddressByYxUserAddressId")
    public DataResult selectYxUserAddressByYxUserAddressId(Integer YxUserAddressId) {

        YxUserAddress yxUserAddress = yxUserAddressMapper.selectById(YxUserAddressId);
        return DataResult.ok(yxUserAddress);
    }


    /**
     * 修改地址
     *
     * @param yxUserAddress
     * @return
     */
    @RequestMapping("/updateYxUserAddress")
    public DataResult updateYxUserAddress(YxUserAddress yxUserAddress) {

        //查询是否有默认地址
        QueryWrapper<YxUserAddress> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uid", yxUserAddress.getUid()).eq("is_default", 0).eq("is_del", 0);
        List<YxUserAddress> yxUserAddresses = yxUserAddressMapper.selectList(queryWrapper);
        YxUserAddress userAddress = null;
        if (!CollectionUtils.isEmpty(yxUserAddresses)) {
            userAddress = yxUserAddresses.get(0);
        }
        if (userAddress != null) {
            userAddress.setIsDefault(1);
            yxUserAddressService.updateYxUserAddress(userAddress);
        }
        yxUserAddressService.updateYxUserAddress(yxUserAddress);
        return DataResult.ok("1");
    }


    /**
     * 删除地址
     *
     * @param yxUserAddress
     * @return
     */
    @RequestMapping("/deleteYxUserAddress")
    public DataResult deleteYxUserAddress(YxUserAddress yxUserAddress) {
        yxUserAddress.setIsDel(1);//删除
        int count = yxUserAddressService.updateYxUserAddress(yxUserAddress);
        if (count > 0) {
            return DataResult.ok("1");
        }
        return DataResult.build(300, "失败");
    }


    /**
     * 查询我的发布详情
     *
     * @param infoId
     * @param accessType 1   司机招聘  2   司机找工作  3   找机械   4   二手机械出售     5   找工程 6   物流信息 7   托运信息 8去租赁
     * @return
     */
    @RequestMapping("/selectDriverInfoBytypeId")
    public DataResult selectDriverInfoBytypeId(Integer infoId, Integer accessType, String userId) {

        if (accessType == 1) {
            DriverInfo driverInfo = driverInfoService.selectDriverInfoBytypeId(infoId);
            driverInfo.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    driverInfo.setCollect(1);
                }
            }
            return DataResult.ok(driverInfo);
        } else if (accessType == 2) {
            DriverWorkInfo driverWorkInfo = driverWorkInfoService.selectDriverWorkInfoByTypeId(infoId);
            driverWorkInfo.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    driverWorkInfo.setCollect(1);
                }
            }
            return DataResult.ok(driverWorkInfo);
        } else if (accessType == 3) {
            MachineBuy machineBuy = machineBuyService.selectMachineBuyByTypeId(infoId);
            machineBuy.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    machineBuy.setCollect(1);
                }
            }
            return DataResult.ok(machineBuy);
        } else if (accessType == 4) {
            MachineSell machineSell = machineSellService.selectMachineSellByTypeId(infoId);
            machineSell.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    machineSell.setCollect(1);
                }
            }
            return DataResult.ok(machineSell);
        } else if (accessType == 5) {
            ProjectSeek projectSeek = projectSeekService.selectProjectByTypeId(infoId);
            projectSeek.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    projectSeek.setCollect(1);
                }
            }
            return DataResult.ok(projectSeek);
        } else if (accessType == 6) {
            TransportCompanyInfo transportCompanyInfo = transportCompanyInfoService.selectTransportCompanyInfoByTypeId(infoId);
            transportCompanyInfo.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    transportCompanyInfo.setCollect(1);
                }
            }
            return DataResult.ok(transportCompanyInfo);
        } else if (accessType == 7) {
            TransportInfo transportInfo = transportInfoService.selectTransportInfoByTypeId(infoId);
            transportInfo.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    transportInfo.setCollect(1);
                }
            }
            return DataResult.ok(transportInfo);
        } else {
            Lease lease = leaseService.selectLeaseByLeadeIds(infoId);
            lease.setCollect(0);
            if (StringUtils.isNotEmpty(userId)) {
                int count = infoCollectService.selectInfoCollectCount(userId, infoId, accessType);
                if (count > 0) {
                    lease.setCollect(1);
                }
            }
            return DataResult.ok(lease);
        }
    }


    /**
     * 删除我的发布
     *
     * @param infoId
     * @param accessType 1   司机招聘  2   司机找工作  3   找机械   4   二手机械出售     5   找工程 6   物流信息 7   托运信息  8去租赁
     * @return
     */
    @RequestMapping("/deleteDriverInfoBytypeId")
    public DataResult deleteDriverInfoBytypeId(Integer infoId, Integer accessType) {
        if (accessType == 1) {
            DriverInfo driverInfo = driverInfoMapper.selectById(infoId);
            driverInfo.setDelFlag(1);
            return DataResult.ok(driverInfoMapper.updateById(driverInfo));
        } else if (accessType == 2) {
            DriverWorkInfo driverWorkInfo = driverWorkInfoMapper.selectById(infoId);
            driverWorkInfo.setDelFlag(1);
            return DataResult.ok(driverWorkInfoMapper.updateById(driverWorkInfo));
        } else if (accessType == 3) {
            MachineBuy machineBuy = machineBuyMapper.selectById(infoId);
            machineBuy.setDelFlag(1);
            return DataResult.ok(machineBuyMapper.updateById(machineBuy));
        } else if (accessType == 4) {
            MachineSell machineSell = machineSellMapper.selectById(infoId);
            machineSell.setDelFlag(1);
            return DataResult.ok(machineSellMapper.updateById(machineSell));
        } else if (accessType == 5) {
            ProjectSeek projectSeek = projectSeekMapper.selectById(infoId);
            projectSeek.setDelFlag(1);
            return DataResult.ok(projectSeekMapper.updateById(projectSeek));
        } else if (accessType == 6) {
            TransportCompanyInfo transportCompanyInfo = transportCompanyInfoMapper.selectById(infoId);
            transportCompanyInfo.setDelFlag(1);
            return DataResult.ok(transportCompanyInfoMapper.updateById(transportCompanyInfo));
        } else if (accessType == 7) {
            TransportInfo transportInfo = transportInfoMapper.selectById(infoId);
            transportInfo.setDelFlag(1);
            return DataResult.ok(transportInfoMapper.updateById(transportInfo));
        } else {
            Lease lease = leaseMapper.selectById(infoId);
            lease.setDelFlag(1);
            return DataResult.ok(leaseMapper.updateById(lease));
        }
    }


    /**
     * 查询我收藏的店铺
     *
     * @param userId
     * @return
     */
    @RequestMapping("/selectUserShopCollects")
    public DataResult selectUserShopCollects(Integer page, Integer limit, Integer userId) {

        PageHelper.startPage(page, limit, true);
        List<UserShopCollect> list = userShopCollectService.selectUserShopCollects(userId);
        PageInfo<UserShopCollect> pages = new PageInfo<>(list);
        return DataResult.ok(pages);
    }

    /**
     * 删除我收藏的店铺
     *
     * @param userShopCollect
     * @return
     */
    @RequestMapping("/deleteUserShopCollects")
    public DataResult deleteUserShopCollects(UserShopCollect userShopCollect) {
        QueryWrapper<UserShopCollect> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uid", userShopCollect.getUid()).eq("shop_id", userShopCollect.getShopId());
        int count = userShopCollectMapper.delete(queryWrapper);
        if (count > 0) {
            return DataResult.ok("1");
        }
        return DataResult.build(300, "删除失败");
    }


    /**
     * 查询我的资料库
     *
     * @param userId
     * @return
     */
    @RequestMapping("/selectVipArticleCollects")
    public DataResult selectVipArticleCollects(Integer page, Integer limit, Integer userId) {

        PageHelper.startPage(page, limit, true);
        List<VipArticleCollect> list = vipArticleCollectService.selectVipArticleCollects(userId);
        PageInfo<VipArticleCollect> pages = new PageInfo<>(list);
        return DataResult.ok(pages);
    }

    /**
     * 根据资料id查询我的资料详情
     *
     * @param vipArticlId
     * @return
     */
    @RequestMapping("/selectVipArticlesByVipArticlId")
    public DataResult selectVipArticlesByVipArticlId(Integer vipArticlId) {
        VipArticle vipArticle = vipArticleMapper.selectById(vipArticlId);
        if (vipArticle != null) {
            Classify classify = classifyMapper.selectById(vipArticle.getClassifyId());
            vipArticle.setClassifyName(classify.getClassifyName());
            return DataResult.ok(vipArticle);
        }
        return DataResult.build(300, "查询失败");

    }

    /**
     * 删除我的资料
     *
     * @param vipArticleCollect
     * @return
     */
    @RequestMapping("/deleteVipArticleCollects")
    public DataResult deleteVipArticleCollects(VipArticleCollect vipArticleCollect) {
        QueryWrapper<VipArticleCollect> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uid", vipArticleCollect.getUid()).eq("article_id", vipArticleCollect.getArticleId());

        int count = vipArticleCollectMapper.delete(queryWrapper);
        if (count > 0) {
            return DataResult.ok("1");
        }
        return DataResult.build(300, "删除失败");
    }


    /**
     * 增加发布浏览量
     *
     * @param infoId
     * @param accessType 1   司机招聘  2   司机找工作  3   找机械   4   二手机械出售     5   找工程 6   物流信息 7   托运信息  8去租赁
     * @return
     */
    @RequestMapping("/updateDriverInfoBytypeId")
    public DataResult updateDriverInfoBytypeId(Integer infoId, Integer accessType) {
        if (accessType == 1) {
            DriverInfo driverInfo = driverInfoMapper.selectById(infoId);
            driverInfo.setCountNumber(driverInfo.getCountNumber() + 1);
            return DataResult.ok(driverInfoMapper.updateById(driverInfo));
        } else if (accessType == 2) {
            DriverWorkInfo driverWorkInfo = driverWorkInfoMapper.selectById(infoId);
            driverWorkInfo.setCountNumber(driverWorkInfo.getCountNumber() + 1);
            return DataResult.ok(driverWorkInfoMapper.updateById(driverWorkInfo));
        } else if (accessType == 3) {
            MachineBuy machineBuy = machineBuyMapper.selectById(infoId);
            machineBuy.setCountNumber(machineBuy.getCountNumber() + 1);
            return DataResult.ok(machineBuyMapper.updateById(machineBuy));
        } else if (accessType == 4) {
            MachineSell machineSell = machineSellMapper.selectById(infoId);
            machineSell.setCountNumber(machineSell.getCountNumber() + 1);
            return DataResult.ok(machineSellMapper.updateById(machineSell));
        } else if (accessType == 5) {
            ProjectSeek projectSeek = projectSeekMapper.selectById(infoId);
            projectSeek.setCountNumber(projectSeek.getCountNumber() + 1);
            return DataResult.ok(projectSeekMapper.updateById(projectSeek));
        } else if (accessType == 6) {
            TransportCompanyInfo transportCompanyInfo = transportCompanyInfoMapper.selectById(infoId);
            transportCompanyInfo.setCountNumber(transportCompanyInfo.getCountNumber() + 1);
            return DataResult.ok(transportCompanyInfoMapper.updateById(transportCompanyInfo));
        } else if (accessType == 7) {
            TransportInfo transportInfo = transportInfoMapper.selectById(infoId);
            transportInfo.setCountNumber(transportInfo.getCountNumber() + 1);
            return DataResult.ok(transportInfoMapper.updateById(transportInfo));
        } else {
            Lease lease = leaseMapper.selectById(infoId);
            lease.setCountNumber(lease.getCountNumber() + 1);
            return DataResult.ok(leaseMapper.updateById(lease));
        }
    }

    /**
     * 查询维护修养
     *
     * @param provinceCode
     * @return
     */
    @RequestMapping("/selectBywhShops")
    public DataResult selectBywhShops(Integer page, Integer limit, String provinceCode) {

        PageHelper.startPage(page, limit, true);
        List<BywhShop> list = bywhShopService.selectBywhShops(provinceCode);
        PageInfo<BywhShop> pages = new PageInfo<>(list);
        return DataResult.ok(pages);
    }


    /**
     * 根据id查询维护修养详情
     *
     * @param id
     * @return
     */
    @RequestMapping("/selectBywhShopsById")
    public DataResult selectBywhShopsById(Integer id) {
        BywhShop bywhShop = bywhShopMapper.selectById(id);

        return DataResult.ok(bywhShop);
    }


    /**
     * 查询新机展(废弃)
     *
     * @param brandId  品牌id
     * @param cateId   分类id
     * @param priceId  价格区间id
     * @param showName 名称
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("/selectMachineShowsBYCondit")
    public DataResult selectMachineShowsBYCondit(@Param("brandId") Integer brandId, @Param("cateId") Integer cateId,
                                                 @Param("priceId") Integer priceId, @Param("showName") String showName,
                                                 @Param("modelId") Integer modelId,
                                                 Integer page, Integer limit) {

        PageHelper.startPage(page, limit, true);
        List<MachineShow> list = machineShowService.selectMachineShowsBYCondit(showName, brandId, cateId, priceId, modelId);

        //查询品牌名称
        for (MachineShow machineShow : list) {
            QueryWrapper<ProductBrand> listb = new QueryWrapper<>();
            listb.eq("id", machineShow.getBrandId());
            ProductBrand brand = productBrandMapper.selectOne(listb);
            machineShow.setBrandName(machineShow.getBrandId() == null ? null : brand.getName());
        }

        PageInfo<MachineShow> pages = new PageInfo<>(list);
        return DataResult.ok(pages);
    }


    /**
     * 根据id查询新机展详情(废弃)
     *
     * @param showId
     * @return
     */
    @RequestMapping("/selectMacgineShowbyShowId")
    public DataResult selectMacgineShowbyShowId(Integer showId) {

        return DataResult.ok(machineShowService.selectMacgineShowbyShowId(showId));
    }

}

